package com.house.mapper;

import com.house.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    //根据用户名查询用户
    @Select("select * from rental_user where username=#{username}")
    User findByUsername(String username);

    //添加
    @Insert("insert  into rental_user(username,password,role,created_at,updated_at)"+
            "values (#{username},#{password},#{role},now(),now())")
    void add(String username, String password, String role);

    //更新
    @Update("update rental_user set email=#{email},updated_at=#{updated_at} where id=#{id}")
    void update(User user);

    //更新用户密码
    @Update("update rental_user set password=#{md5String},updated_at=now() where id=#{id}")
    void updatePwd(String md5String, Integer id);
}
